import QtQuick 2.12

Rectangle {
    width: parent.width
    height: 300
    color: "transparent"
    border.width: 2
    radius: 20

    property int lineNum: 1
    property var arrModel: []
    property bool showIndicator: true

    signal sigClicked(string zhulanId, string weight)

    Text {
        id: lineTxt
        text: lineNum + "号线"
        font.pixelSize: 16
        anchors.left: parent.left
        anchors.top: parent.top
        anchors.leftMargin: 20
        anchors.topMargin: 20
    }

    ListView {
        id: lvv
        clip: true
        anchors.fill: parent
        anchors.leftMargin: 20
        anchors.topMargin: 50
        spacing: 10
        width: parent.width
        orientation: ListView.Horizontal
        delegate: ZhuLan {
            zhulanNum: model.index+1
            weight: model.weight
            feedCountToday: model.feedCountToday ? model.feedCountToday : "no"
            feedState: model.feedState ? model.feedState : "no"
            m_bShowInd: showIndicator
            zhulanId: lineNum+"_"+(model.index+1)

            onSigZhulanClicked: {
                emit: sigClicked(zhulanId, weight)
            }
        }

        model: arrModel

//        model: ListModel {
//            id: lmodel
//            ListElement {
//                weight: 50
//                feedCountToday: 1
//                feedState: "fed"
//            }

//            ListElement {
//                weight: 60
//                feedCountToday: 1
//                feedState: "fed"
//            }

//            ListElement {
//                weight: 57
//                feedCountToday: 1
//                feedState: "fed"
//            }

//            ListElement {
//                weight: 56
//                feedCountToday: 1
//                feedState: "fed"
//            }

//            ListElement {
//                weight: 52
//                feedCountToday: 1
//                feedState: "fed"
//            }

//            ListElement {
//                weight: 58
//                feedCountToday: 1
//                feedState: "feeding"
//            }

//            ListElement {
//                weight: 50
//                feedCountToday: 1
//                feedState: "notfed"
//            }

//        }
    }

    function setModel(ms) {
        console.log("ms: ", JSON.stringify(ms))
        lmodel.clear()
        for (var i=0; i<ms.length; ++i) {
            print("iiii: ", i)
            print("ms i: ", ms[i])
            lmodel.append(ms[i])
        }
    }
}
